//
//  MCGroupPaymentNewModel.m
//  XDYL
//
//  Created by MC on 2018/3/27.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCGroupPaymentNewModel.h"
#import "NSDictionary+helper.h"
#import "NSString+Helper.h"
@interface MCPaymentNewModel ()

@end
@implementation MCPaymentNewModel

@end

@implementation MCPayTypeModel

@end
@interface MCGroupPaymentNewModel ()<ApiManagerCallBackProtocol,ApiManagerProvider,ApiManagerProtocol>


@end

@implementation MCGroupPaymentNewModel
singleton_m(MCGroupPaymentNewModel)

- (void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
};
-(BOOL)isShowHud{
    return YES;
}
- (BOOL)isShowError{
    return NO;
}
- (BOOL)isShowNoNet{
    return NO;
}
- (BOOL)isShowNodata{
    return NO;
}
- (enum ManagerRequestMethod)requestMethod{
    
    return ManagerRequestMethodRequestMethodRestPOST;
}

- (enum APIResponseDataType)responseDataType{
    
    return APIResponseDataTypeJson;
}
- (void)refreashDataAndShow{
    
    ApiBaseManager *baseManager = [[ApiBaseManager alloc] initWithUrlProvider:self];
    baseManager.apiCallBackDelegate = self;
    baseManager.requestCustomizeDelegate = self;
    [baseManager loadData];
    
}

- (NSDictionary<NSString *,NSString *> *)headerForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *Token=@"";
    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"token"]) {
        Token=[[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
    }
    
    return @{@"token":Token,@"platformCode":@"5"};
}

- (NSString *)urlPathComponentForManagerWithManager:(ApiBaseManager *)manager{
    
    return @"web-api/api/v4/get_group_payment";
    
}

- (NSDictionary<NSString *,id> *)parametersForManagerWithManager:(ApiBaseManager *)manager{
    
    NSString *timeString = [NSString getCurrentTimestamp];
    
    NSDictionary *dic =@{};
    
    NSString *jsonStr = [dic convertToJsonData];
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",jsonStr,[[NSUserDefaults standardUserDefaults] objectForKey:@"token"],timeString];
    return @{@"params":jsonStr,
             @"sign":[sign MD5],
             @"timestamp":timeString
             };
}

- (void)managerCallAPIDidSuccessWithManager:(ApiBaseManager *)manager{
    
    //    [BKIndicationView dismiss];
    if (self.callBackSuccessBlock) {
        self.callBackSuccessBlock(manager);
    }
    
}

- (void)managerCallAPIDidFailedWithManager:(ApiBaseManager *)manager errorCode:(NSString *)errorCode{
    //    [BKIndicationView dismiss];
    if (self.callBackFailedBlock) {
        self.callBackFailedBlock(manager,errorCode);
    }
    NSLog(@"er=----%@",errorCode);
}

-(void)setPayMentArrWithData:(NSDictionary *)dic{
    
    self.payMentArr=[[NSMutableArray alloc]init];
    self.AllRecMethod=[[NSMutableArray alloc]init];
    [self.payMentArr removeAllObjects];
    [self.AllRecMethod removeAllObjects];
    NSDictionary * MoneyCenterUserInfo = dic[@"MoneyCenterUserInfo"];
    NSArray * Context = MoneyCenterUserInfo[@"Context"];
    NSDictionary * Context_1 = Context[0];
    NSArray * AllRecMethod = Context_1[@"AllRecMethod"];
    NSArray * AllRecPay = Context_1[@"AllRecPay"];
    
    self.AllRecPay=AllRecPay;
    
    
    for (NSDictionary * tempp1 in AllRecMethod) {
        MCPayTypeModel * PayTypeModel = [[MCPayTypeModel alloc]init];
        PayTypeModel.ID=[NSString stringWithFormat:@"%@",tempp1[@"ID"]];
        PayTypeModel.ClientPayTypeName=[NSString stringWithFormat:@"%@",tempp1[@"ClientPayTypeName"]];//":"微信支付",
        PayTypeModel.PicCode=[NSString stringWithFormat:@"%@",tempp1[@"PicCode"]];//":"icon-weixinzhifu"
        PayTypeModel.Order=[NSString stringWithFormat:@"%@",tempp1[@"Order"]];//":"17",
        PayTypeModel.SysId=[NSString stringWithFormat:@"%@",tempp1[@"SysId"]];//":02e72064-bee5-4875-8894-6fd796326c4d
        
        if ([PayTypeModel.PicCode isEqualToString:@"icon-zhifubao"]) {
            //支付宝
            PayTypeModel.logoType=@"1";
            
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-weixinzhifu"]){
            //微信
            PayTypeModel.logoType=@"2";
            
        }else if ([PayTypeModel.PicCode isEqualToString:@"icon-lianxiwomenqq"]){
            
            //QQ
            PayTypeModel.logoType=@"3";
            
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-kuaijiezhifu"]){
            //快捷
            PayTypeModel.logoType=@"5";
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-jingdong"]){
            //京东
            PayTypeModel.logoType=@"6";
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-baidu"]){
            //百度
            PayTypeModel.logoType=@"7";
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-yinlian1193427easyiconnet"]){
            //银联
            PayTypeModel.logoType=@"8";
            
        }else if([PayTypeModel.PicCode isEqualToString:@"icon-yinxingqia002"]){
            //网银转账
            PayTypeModel.logoType=@"4";
        }else{
            //默认
            PayTypeModel.logoType=@"9";
        }
        
        NSMutableArray *payType=[[NSMutableArray alloc]init];
        
        NSArray * arr_2 = tempp1[@"payType"];
        for (NSDictionary *tempp2  in arr_2) {
            MCPaymentNewModel * model = [[MCPaymentNewModel alloc]init];
            
            model.BankList=tempp2[@"BankList"];
            
            model.PayInType=[NSString stringWithFormat:@"%@",tempp2[@"PayInType"]];//":"52",
            model.MinRecMoney=[NSString stringWithFormat:@"%@",tempp2[@"MinRecMoney"]];//":"0",
            model.MaxRecMoney=[NSString stringWithFormat:@"%@",tempp2[@"MaxRecMoney"]];//":"50000",
            model.PayName=[NSString stringWithFormat:@"%@",tempp2[@"PayName"]];//":"华仁支付(快捷支付)",
            model.Order=[NSString stringWithFormat:@"%@",tempp2[@"Order"]];//":"17",
            model.SysId=[NSString stringWithFormat:@"%@",tempp2[@"SysId"]];//":"2b7a2c9b-41a9-4197-96d6-77d5c942a8d3",
            model.BankCode=[NSString stringWithFormat:@"%@",tempp2[@"BankCode"]];//":""
            
            model.ID=[NSString stringWithFormat:@"%@",tempp1[@"ID"]];//":1,
            model.ClientPayTypeName=[NSString stringWithFormat:@"%@",tempp1[@"ClientPayTypeName"]];//":"微信支付",
            model.PicCode=[NSString stringWithFormat:@"%@",tempp1[@"PicCode"]];//"
            model.RealPayName=[NSString stringWithFormat:@"%@",tempp2[@"RealPayName"]];//"
            model.logoType=PayTypeModel.logoType;
            
            NSString * FeeType = [NSString stringWithFormat:@"%@",tempp2[@"FeeType"]];
            if (FeeType.length>0&& ![FeeType containsString:@"null"]) {
               model.FeeType = FeeType;//";
            }else{
                model.FeeType = @"";
            }
            NSString * FeeMoney = [NSString stringWithFormat:@"%@",tempp2[@"FeeMoney"]];
            if (FeeMoney.length>0&& ![FeeMoney containsString:@"null"]) {
                model.FeeMoney = FeeMoney;// GetRealSNum(FeeMoney);//";
            }else{
                model.FeeMoney = @"0";
            }
            NSString * CappingMoney = [NSString stringWithFormat:@"%@",tempp2[@"CappingMoney"]];
            if (CappingMoney.length>0&& ![CappingMoney containsString:@"null"]) {
                model.CappingMoney = CappingMoney;//GetRealSNum(CappingMoney);//";
            }else{
                model.CappingMoney = @"0";
            }
            
            [payType addObject:model];
            
        }
        
        PayTypeModel.payType=payType;
        
        if (PayTypeModel.payType.count>0) {
            [self.AllRecMethod addObject:PayTypeModel];
        }
        
    }
    
    for (NSDictionary * temp1 in AllRecMethod) {
        NSArray * arr2 = temp1[@"payType"];
        
        for (NSDictionary *temp2  in arr2) {
            
            MCPaymentNewModel * model = [[MCPaymentNewModel alloc]init];
            
            model.BankList=temp2[@"BankList"];
            
            model.PayInType=[NSString stringWithFormat:@"%@",temp2[@"PayInType"]];//":"52",
            model.MinRecMoney=[NSString stringWithFormat:@"%@",temp2[@"MinRecMoney"]];//":"0",
            model.MaxRecMoney=[NSString stringWithFormat:@"%@",temp2[@"MaxRecMoney"]];//":"50000",
            model.PayName=[NSString stringWithFormat:@"%@",temp2[@"PayName"]];//":"华仁支付(快捷支付)",
            model.Order=[NSString stringWithFormat:@"%@",temp2[@"Order"]];//":"17",
            model.SysId=[NSString stringWithFormat:@"%@",temp2[@"SysId"]];//":"2b7a2c9b-41a9-4197-96d6-77d5c942a8d3",
            model.BankCode=[NSString stringWithFormat:@"%@",temp2[@"BankCode"]];//":""
            
            model.ID=[NSString stringWithFormat:@"%@",temp1[@"ID"]];//":1,
            model.ClientPayTypeName=[NSString stringWithFormat:@"%@",temp1[@"ClientPayTypeName"]];//":"微信支付",
            model.PicCode=[NSString stringWithFormat:@"%@",temp1[@"PicCode"]];//"
            NSString * FeeType = [NSString stringWithFormat:@"%@",temp2[@"FeeType"]];
            if (FeeType.length>0&& ![FeeType containsString:@"null"]) {
                model.FeeType = FeeType;//";
            }else{
                model.FeeType = @"";
            }
            NSString * FeeMoney = [NSString stringWithFormat:@"%@",temp2[@"FeeMoney"]];
            if (FeeMoney.length>0&& ![FeeMoney containsString:@"null"]) {
                model.FeeMoney = FeeMoney;//";
            }else{
                model.FeeMoney = @"0";
            }
            NSString * CappingMoney = [NSString stringWithFormat:@"%@",temp2[@"CappingMoney"]];
            if (CappingMoney.length>0&& ![CappingMoney containsString:@"null"]) {
                model.CappingMoney = CappingMoney;//";
            }else{
                model.CappingMoney = @"0";
            }

            
            //支付宝     icon-zhifubao
            //微信支付   icon-weixinzhifu
            //QQ钱包     icon-lianxiwomenqq
            //百度钱包   icon-baidu
            //京东钱包   icon-jingdong
            //快捷支付   icon-kuaijiezhifu
            //银联钱包   icon-yinlian1193427easyiconnet
            //网银转账   icon-yinxingqia002
            
            if ([model.PicCode isEqualToString:@"icon-zhifubao"]) {
                //支付宝
                model.logoType=@"1";
                
                
            }else if([model.PicCode isEqualToString:@"icon-weixinzhifu"]){
                //微信
                model.logoType=@"2";
                
            }else if ([model.PicCode isEqualToString:@"icon-lianxiwomenqq"]){
                
                //QQ
                model.logoType=@"3";
                
                
            }else if([model.PicCode isEqualToString:@"icon-kuaijiezhifu"]){
                //快捷
                model.logoType=@"5";
                
            }else if([model.PicCode isEqualToString:@"icon-jingdong"]){
                //京东
                model.logoType=@"6";
                
            }else if([model.PicCode isEqualToString:@"icon-baidu"]){
                //百度
                model.logoType=@"7";
                
            }else if([model.PicCode isEqualToString:@"icon-yinlian1193427easyiconnet"]){
                //银联
                model.logoType=@"8";
                
            }else if([model.PicCode isEqualToString:@"icon-yinxingqia002"]){
                //网银转账
                model.logoType=@"4";
            }else{
                //默认
                model.logoType=@"9";
            }
            
            [self.payMentArr addObject:model];
            
        }
    }
    
}

@end

/*
 {
 DataCount = 0;
 GetUserGroupPayList =     (
 );
 MoneyCenterUserInfo =     {
 Context =         (
 {
 AllRecMethod =                 (
 {
 ClientPayTypeName = "\U652f\U4ed8\U5b9d\U652f\U4ed8";
 ID = 2;
 Order = 3;
 PicCode = "icon-zhifubao";
 SysId = "300fe200-fcbe-44c8-bb5f-bee10b1a7947";
 payType =                         (
 {
 BankCode = "";
 BankList =                                 (
 );
 MaxRecMoney = 10000;
 MinRecMoney = 0;
 Order = 19;
 PayInType = 58;
 PayName = "\U534e\U4ec1\U652f\U4ed8(QQPay)";
 SysId = "4a5acf02-4a45-4eb2-8d56-b4d68cde6e66";
 }
 );
 },
 {
 ClientPayTypeName = "\U7f51\U94f6\U8f6c\U8d26";
 ID = 7;
 Order = 7;
 PicCode = "icon-yinxingqia002";
 SysId = "4e22c885-d617-4ce6-b917-723ed706e2f0";
 payType =                         (
 {
 BankCode = CMBC;
 BankList =                                 (
 );
 MaxRecMoney = 50000;
 MinRecMoney = 50;
 Order = 3;
 PayInType = 156;
 PayName = "\U6c11\U751f\U94f6\U884c";
 SysId = "f644827a-875b-4dc0-8ae0-4dd7c7a73f37";
 }
 );
 }
 );
 AllRecPay =                 (
 {
 Pay = 58;
 PayName = "\U534e\U4ec1\U652f\U4ed8(QQPay)";
 SortNum = 19;
 },
 {
 Pay = 156;
 PayName = "\U6c11\U751f\U94f6\U884c";
 SortNum = 3;
 }
 );
 BCard = 23423432432543435;
 Bank = comm;
 Bname = "\U8bb8\U5efa\U519b";
 Email = "";
 IdCard = "";
 PostCode = "";
 RegisterIp = "--_192.168.1.196";
 RegisterTime = "06/20/2017 14:31:03";
 Sex = 1;
 UInfoname = "";
 UserAddress = "";
 isValid = 1;
 userid = 16762;
 }
 );
 Result = 1;
 };
 OrderState = 0;
 PageCount = 0;
 SystemState = kStatusBarAndNavigationBarHeight;
 }
 */










